<?php

namespace app\model\user;

use app\base\BaseModel;
use think\model\concern\SoftDelete;

/**
 * 模型-UserSuggestModel
 * Class UserSuggestModel
 * @package app\model
 */
class UserSuggestModel extends BaseModel
{

    protected $name = 'user_suggest';

    /**
     * 获取分页列表
     * @param $current_page
     * @param $list_rows
     * @param string $field
     * @return array
     */
    public function getPageData($current_page, $list_rows, $field = '*')
    {
        $dataList = $this
            ->field($field)
            ->order('add_time', 'desc')
            ->paginate(['page' => $current_page, 'list_rows' => $list_rows], false);
        $current = $dataList->currentPage();
        $total = $dataList->total();
        $limit = $dataList->listRows();
        $ret = ['total' => $total, 'current' => $current, 'limit' => $limit, 'dataList' => $dataList->items()];
        return $ret;
    }

    /**
     * 添加反馈意见
     * @param $user_id
     * @param $content
     * @return bool
     */
    public static function addContent($user_id, $content)
    {
        $in_data = [
            'user_id' => $user_id,
            'content' => $content,
            'add_time' => time()
        ];
        $ret = self::insert($in_data);
        if ($ret === false) {
            return false;
        }
        return true;
    }
}